<!doctype html>
<html lang="en">
<head>
	<meta charset="UTF-8">	
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<link rel="stylesheet" href="./../assets/css/combined.css">
	<script src="http://www.google.com/jsapi" type="text/javascript"></script>
	<script type="text/javascript">
		var path = './../';
		var class_prefix = "Pagination::";
	</script>
	<script src="./../assets/js/combined.js"></script>
	<title>Pagination - Classes - FuelPHP Documentation</title>
</head>
<body>
	<div id="container">
		<header id="header">
			<div class="table">
				<h1>
					<strong>FuelPHP, a PHP 5.3 Framework</strong>
					Documentation
				</h1>
				
				<form id="google_search">
					<p>
						<span id="search_clear">&nbsp;</span>
						<input type="submit" name="search_submit" id="search_submit" value="search" />
						<input type="text" value="" id="search_input" name="search_input" />						
					</p>
				</form>
			</div>
			<nav>
				
				<div class="clear"></div>
			</nav>
			<a href="#" id="toc_handle">table of contents</a>
			<div class="clear"></div>
		</header>
		
		<div id="cse">
			<div id="cse_point"></div>
			<div id="cse_content"></div>
		</div>
		
		<div id="main">
			
			<h2>Pagination Class</h2>
	
			<p>The pagination class allows you to easily setup pagination for records you display.</p>
	
			<section>
				<h3 id="how_to">How To</h3>
				<p>A simple example on how to use the Pagination class, the <strong>set_config</strong> method is used in this example. You can put this inside your action methods in your controller.
				<pre class="php"><code>$config = array(
	'pagination_url' => 'http://localhost/fuel/welcome/index/',
	'total_items' => 10,
	'per_page' => 5,
	'uri_segment' => 3,
	'template' => array(
		'wrapper_start' => '&lt;div class="my-pagination"&gt; ',
		'wrapper_end' => ' &lt;/div&gt;',
	),
);

// Config::set('pagination', $config); // you can use this too!
Pagination::set_config($config);

$data['example_data'] = DB::select('id', 'value')->from('pagination')
												->limit(Pagination::$per_page)
												->offset(Pagination::$offset)
												->execute()
												->as_array();

$data['pagination'] = Pagination::create_links();
$this->render('welcome/index', $data);</code></pre>
			</section>
	
			<section>
				<h3 id="configuration">Configuration</h3>
	
				<p>You can configure the pagination using two methods either by using the <strong>set_config</strong> method or by setting a global config array.</p>
				<p>The following configuration settings can be defined:</p>
				<table class="config">
					<tbody>
						<tr class="header">
							<th>Param</th>
							<th>Type</th>
							<th>Default</th>
							<th>Description</th>
						</tr>
						<tr>
							<th>pagination_url</th>
							<td>string</td>
							<td>None</td>
							<td>
								The URL of page where you have pagination.
							</td>
						</tr>
						<tr>
							<th>uri_segment</th>
							<td>integer</td>
							<td><pre class="php"><code>3</code></pre></td>
							<td>
								The URI segment containing the page number.
							</td>
						</tr>
						<tr>
							<th>num_links</th>
							<td>integer</td>
							<td><pre class="php"><code>5</code></pre></td>
							<td>
								The total number of links to show.
							</td>
						</tr>
						<tr>
							<th>total_items</th>
							<td>integer</td>
							<td><pre class="php"><code>0</code></pre></td>
							<td>
								The total number of items.
							</td>
						</tr>
						<tr>
							<th>total_pages</th>
							<td>integer</td>
							<td><pre class="php"><code>0</code></pre></td>
							<td>
								The total number of pages.
							</td>
						</tr>
						<tr>
							<th>per_page</th>
							<td>integer</td>
							<td><pre class="php"><code>10</code></pre></td>
							<td>
								The number of items per page.
							</td>
						</tr>
						<tr>
							<th>template</th>
							<td>array</td>
							<td><pre class="php"><code></code></pre></td>
							<td>
								Associative array containing the HTML markup to create the pagination elements (see Global Config Array section for the list of array keys w/ default values).
							</td>
						</tr>
					</tbody>
				</table>
			</section>
	
			<section>
				<article>
					<h4 id="global_config">Global Config Array</h4>
					<p>This method allows you to set the pagination configuration by setting a global config array.
					<pre class="php"><code>Config::set('pagination', array(
	'pagination_url' => 'http://docs.fuelphp.com/',
	'uri_segment' => 2,
	'total_items' => 10,
	'per_page' => 20,
	'template' => array(
		'wrapper_start' => '&lt;div class="pagination"&gt; ',
		'wrapper_end' => ' &lt;/div&gt;',
		'page_start' => '&lt;span class="page-links"&gt; ',
		'page_end' => ' &lt;/span&gt;',
		'previous_start' => '&lt;span class="previous"&gt; ',
		'previous_end' => ' &lt;/span&gt;',
		'previous_mark' => '&laquo; ',
		'next_start' => '&lt;span class="next"&gt; ',
		'next_end' => ' &lt;/span&gt;',
		'next_mark' => ' &raquo;',
		'active_start' => '&lt;span class="active"&gt; ',
		'active_end' => ' &lt;/span&gt;',
	),
));</code></pre>
				</article>
	
				<article>
					<h4 class="method" id="method_set_config">set_config(array $config)</h4>
					<p>The <strong>set_config</strong> method allows you to set the pagination configuration by passing an array.</p>
					<table class="method">
						<tbody>
						<tr>
							<th class="legend">Static</th>
							<td>Yes</td>
						</tr>
						<tr>
							<th>Parameters</th>
							<td>
								<table class="parameters">
									<tr>
										<th>Param</th>
										<th>Default</th>
										<th class="description">Description</th>
									</tr>
									<tr>
										<th><kbd>$config</kbd></th>
										<td><i>Required</i></td>
										<td>The configuration array.</td>
									</tr>
								</table>
							</td>
						</tr>
						<tr>
							<th>Returns</th>
							<td>void</td>
						</tr>
						<tr>
							<th>Example</th>
							<td>
								<pre class="php"><code>Pagination::set_config(array(
    'pagination_url' => 'http://docs.fuelphp.com/',
	'uri_segment' => 2,
	'total_items' => 10,
	'per_page' => 20,
	'template' => array(
		'wrapper_start' => '&lt;div class="my-pagination-class"&gt; ',
		'wrapper_end'   => ' &lt;/div&gt;',
	),
));</code></pre>
							</td>
						</tr>
						</tbody>
					</table>
				</article>
	
				<article>
					<h4 class="method" id="method_create_links">create_links()</h4>
					<p>The <strong>create_links</strong> method generates the pagination links in the view.</p>
					<table class="method">
						<tbody>
						<tr>
							<th class="legend">Static</th>
							<td>Yes</td>
						</tr>
						<tr>
							<th>Parameters</th>
							<td>None</td>
						</tr>
						<tr>
							<th>Returns</th>
							<td>mixed</td>
						</tr>
						<tr>
							<th>Example</th>
							<td>
								<pre class="php"><code>echo Pagination::create_links();</code></pre>
							</td>
						</tr>
						</tbody>
					</table>
				</article>
	
				<article>
					<h4 class="method" id="method_next_link">next_link($value)</h4>
					<p>The <strong>next_link</strong> method displays a "Next" link for pagination.</p>
					<table class="method">
						<tbody>
						<tr>
							<th class="legend">Static</th>
							<td>Yes</td>
						</tr>
						<tr>
							<th>Parameters</th>
							<td>
								<table class="parameters">
									<tr>
										<th>Param</th>
										<th>Default</th>
										<th class="description">Description</th>
									</tr>
									<tr>
										<th><kbd>$value</kbd></th>
										<td><i>Required</i></td>
										<td>The text displayed in the link.</td>
									</tr>
								</table>
							</td>
						</tr>
						<tr>
							<th>Returns</th>
							<td>mixed</td>
						</tr>
						<tr>
							<th>Example</th>
							<td>
								<pre class="php"><code>echo Pagination::next_link('Next Page');</code></pre>
							</td>
						</tr>
						</tbody>
					</table>
				</article>
	
				<article>
					<h4 class="method" id="method_prev_link">prev_link($value)</h4>
					<p>The <strong>prev_link</strong> method displays a "Previous" link for pagination.</p>
					<table class="method">
						<tbody>
						<tr>
							<th class="legend">Static</th>
							<td>Yes</td>
						</tr>
						<tr>
							<th>Parameters</th>
							<td>
								<table class="parameters">
									<tr>
										<th>Param</th>
										<th>Default</th>
										<th class="description">Description</th>
									</tr>
									<tr>
										<th><kbd>$value</kbd></th>
										<td><i>Required</i></td>
										<td>The text displayed in the link.</td>
									</tr>
								</table>
							</td>
						</tr>
						<tr>
							<th>Returns</th>
							<td>mixed</td>
						</tr>
						<tr>
							<th>Example</th>
							<td>
								<pre class="php"><code>echo Pagination::prev_link('Previous Page');</code></pre>
							</td>
						</tr>
						</tbody>
					</table>
				</article>
	
				<article>
					<h4 class="method" id="method_page_links">page_links()</h4>
					<p>The <strong>page_links</strong> method displays the page links between previous and next links for pagination.</p>
					<table class="method">
						<tbody>
						<tr>
							<th class="legend">Static</th>
							<td>Yes</td>
						</tr>
						<tr>
							<th>Parameters</th>
							<td>None</td>
						</tr>
						<tr>
							<th>Returns</th>
							<td>mixed</td>
						</tr>
						<tr>
							<th>Example</th>
							<td>
								<pre class="php"><code>echo Pagination::page_links();</code></pre>
							</td>
						</tr>
						</tbody>
					</table>
				</article>
			</section>

		</div>

		<footer>
			<p>
				&copy; FuelPHP Development Team 2010-2011 - <a href="http://fuelphp.com">FuelPHP</a> is released under the MIT license.
			</p>
		</footer>
	</div>
</body>
</html>